package liuyuyang.controller;

import liuyuyang.domain.Course;
import liuyuyang.pojo.Result;
import liuyuyang.service.CourseService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/course")
public class CourseController {
    @Resource
    private CourseService courseService;

    @GetMapping("/{id}")
    public Result<List<Course>> get(@PathVariable Integer id){
        return Result.success(courseService.get(id));
    }

    @GetMapping
    public Result<List<Course>> list(){
        return Result.success(courseService.list());
    }
}
